<html>
<head><meta charset="utf-8"><title>Custom stdlib paths · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html">Custom stdlib paths</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="245074992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245074992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245074992">(Jul 06 2021 at 17:52)</a>:</h4>
<p>How do I tell the compiler to use a custom path to a <code>rust-stdlib</code> archive? Is that jsut a simple <code>-L</code> or is there more to be aware of?</p>



<a name="245075293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245075293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245075293">(Jul 06 2021 at 17:55)</a>:</h4>
<p>That is <code>--sysroot</code>.</p>



<a name="245075373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245075373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245075373">(Jul 06 2021 at 17:55)</a>:</h4>
<p>If you want to compile crates for the host (eg build scripts or proc macros) the host libstd needs to be in the sysroot as well.</p>



<a name="245075481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245075481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245075481">(Jul 06 2021 at 17:56)</a>:</h4>
<p>So all libs need to be in the same sysroot?</p>



<a name="245075961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245075961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245075961">(Jul 06 2021 at 17:59)</a>:</h4>
<p>Yes, there can only be one active sysroot at a time and when you use a proc macro, both the host and target libraries need to be available at the same time.</p>



<a name="245076104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245076104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245076104">(Jul 06 2021 at 18:00)</a>:</h4>
<p>Normally you are supposed to install the <code>rust-stdlib</code> to the rustc install dir.</p>



<a name="245077710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245077710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245077710">(Jul 06 2021 at 18:12)</a>:</h4>
<p>Does that mean the rustc libraries need to be in the same location as the stdlibs? That's currently the case I'm trying to work around. I have rustc and it's libraries separate from stdlib</p>



<a name="245082940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245082940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245082940">(Jul 06 2021 at 18:52)</a>:</h4>
<p><span class="user-mention" data-user-id="343063">@UebelAndre</span> If you're trying to build a new target, you might want to start a new conversation about the target with compiler/lang/etc sooner rather than later.</p>



<a name="245084593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245084593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245084593">(Jul 06 2021 at 19:05)</a>:</h4>
<p>It's not for a new target. I'm working on some stuff for Google's build system, Bazel, which individually downloads the rustc artifact and rust-stdlib artifact. So I need to make sure when the compiler is invoked, that the build can find all the required information</p>



<a name="245085478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245085478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245085478">(Jul 06 2021 at 19:12)</a>:</h4>
<p>The preferred way is still merging both directories, but <code>--sysroot</code> should be fine for this case I think. I presume no cross-compilation happens? If it does, you will have to at least merge the rust-stdlib artifacts for the host and target into a single sysroot.</p>



<a name="245095475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245095475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245095475">(Jul 06 2021 at 20:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="343063">UebelAndre</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Custom.20stdlib.20paths/near/245077710">said</a>:</p>
<blockquote>
<p>Does that mean the rustc libraries need to be in the same location as the stdlibs? That's currently the case I'm trying to work around. I have rustc and it's libraries separate from stdlib</p>
</blockquote>
<p>Can you clarify why you're trying to keep those separate, rather than merging them together?</p>



<a name="245097694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245097694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245097694">(Jul 06 2021 at 20:57)</a>:</h4>
<p>Bazel downloads rustc and rust-stdlib separately into different directories. The only way to get them to download to the same directory is to have a single “repository rule” which would download all target platforms you’re potentially interested in, which is wasteful. So the goal is to wire everything up for each call to rustc (which Bazel is good at). But the issue is I’m not clear how I can tell rustc where everything is. <span class="user-mention" data-user-id="239881">@Josh Triplett</span> does that answer the question?</p>



<a name="245097756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245097756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245097756">(Jul 06 2021 at 20:57)</a>:</h4>
<p>Ah, I see. It downloads the standard library separately because you need it per-target?</p>



<a name="245097771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245097771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245097771">(Jul 06 2021 at 20:57)</a>:</h4>
<p>Yes</p>



<a name="245097810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245097810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245097810">(Jul 06 2021 at 20:58)</a>:</h4>
<p>That makes sense.</p>



<a name="245097864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245097864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245097864">(Jul 06 2021 at 20:58)</a>:</h4>
<p>Where the compiler is only needed for the host/execution environment</p>



<a name="245097889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245097889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245097889">(Jul 06 2021 at 20:58)</a>:</h4>
<p>(Right?)</p>



<a name="245097894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245097894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245097894">(Jul 06 2021 at 20:58)</a>:</h4>
<p>That seems relatively reasonable. The idea of having a "host root" and a "target root" makes sense.</p>



<a name="245097939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245097939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245097939">(Jul 06 2021 at 20:59)</a>:</h4>
<p>That’s exactly what I’m after. And am wondering how to wire that up</p>



<a name="245099233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245099233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245099233">(Jul 06 2021 at 21:10)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> is your recommendation also to set —sysroot?</p>



<a name="245101165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245101165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245101165">(Jul 06 2021 at 21:28)</a>:</h4>
<p><span class="user-mention" data-user-id="343063">@UebelAndre</span> I'm suggesting that that functionality doesn't exist today, and would require some amount of additional support in the compiler.</p>



<a name="245101208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245101208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245101208">(Jul 06 2021 at 21:28)</a>:</h4>
<p>I think a compiler MCP would make sense, proposing a <code>--target-root</code> option or similar that overrides sysroot for the target but not for the host.</p>



<a name="245101958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245101958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245101958">(Jul 06 2021 at 21:36)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span>  Ah ok. Does <code>rustc</code> follow symlinks? I may be able to mock the sysroot by symlinking things when it's known they're needed for a particular call to <code>rustc</code></p>



<a name="245102300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102300">(Jul 06 2021 at 21:40)</a>:</h4>
<p>I'd personally prefer to avoid further complicating our strategy for discovering the sysroot and such -- I think there should be alternatives to a target-root, such as symlinks, that seem much preferable</p>



<a name="245102327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102327">(Jul 06 2021 at 21:40)</a>:</h4>
<p>(also, I don't know if it's customary to ping in Zulip but I personally find it to be the only way to keep up with a thread but perhaps my notification settings are incorrect. Either way, not trying to bug you and sorry if I am)</p>



<a name="245102370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102370">(Jul 06 2021 at 21:41)</a>:</h4>
<p>If you're in a system like Bazel or so, you may alternatively explicitly pass the std/core crates via --extern core=/path/to/core -- that should be pretty equivalent to the sysroot, I think</p>



<a name="245102407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102407">(Jul 06 2021 at 21:41)</a>:</h4>
<p>That's also doable</p>



<a name="245102430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102430">(Jul 06 2021 at 21:42)</a>:</h4>
<p>I think we may chase symlinks already today, though not 100% sure on that.</p>



<a name="245102476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102476">(Jul 06 2021 at 21:42)</a>:</h4>
<p>any thoughts on which would be more ergonomic from the perspective of <code>rustc</code>?</p>



<a name="245102519"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102519" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102519">(Jul 06 2021 at 21:42)</a>:</h4>
<p>not sure I understand the question</p>



<a name="245102550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102550">(Jul 06 2021 at 21:43)</a>:</h4>
<p>symlinks are likely easier if we support them and they work well for you</p>



<a name="245102669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102669">(Jul 06 2021 at 21:44)</a>:</h4>
<p>I've run into sutiations with other tools where symlinks were advised against</p>



<a name="245102760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102760">(Jul 06 2021 at 21:45)</a>:</h4>
<p>I'm not immediately aware of any problems.</p>



<a name="245102771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245102771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245102771">(Jul 06 2021 at 21:45)</a>:</h4>
<p>(Though I don't know if everything in the compiler will probably handle them. I think it should).</p>



<a name="245103156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245103156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245103156">(Jul 06 2021 at 21:49)</a>:</h4>
<p>Ok, I can give that a shot or fall back to <code>--extern=/path/to/my.rlib</code></p>



<a name="245103177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245103177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245103177">(Jul 06 2021 at 21:49)</a>:</h4>
<p>or get really sad <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="245103306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245103306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245103306">(Jul 06 2021 at 21:50)</a>:</h4>
<p>We do follow symlinks. I know because I do similar thing to construct a sysroot on nix.</p>



<a name="245103379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245103379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245103379">(Jul 06 2021 at 21:51)</a>:</h4>
<p>Wonderful!</p>



<a name="245103403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245103403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245103403">(Jul 06 2021 at 21:51)</a>:</h4>
<p>How did you set it up for nix?</p>



<a name="245103460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245103460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245103460">(Jul 06 2021 at 21:52)</a>:</h4>
<p>like, at what point do you symlink?</p>



<a name="245103496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245103496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245103496">(Jul 06 2021 at 21:52)</a>:</h4>
<p>(files and/or directories, that sort of thing)</p>



<a name="245103996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245103996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245103996">(Jul 06 2021 at 21:58)</a>:</h4>
<p>I've a build rule like this:</p>
<div class="codehilite"><pre><span></span><code>  leanRust =
    flip mapAttrs super.latest.rustChannels (name: value: value // {
      rust = super.symlinkJoin {
        name = &quot;rust&quot;;
        paths = [
          (value.rustc.override {})
          (value.cargo.override {})
          (value.rust-std.override {})
          (value.rust-src.override {})
        ];
        postBuild = &#39;&#39;
          cp -L --remove-destination &quot;$(readlink $out/bin/rustc)&quot; $out/bin/rustc
          cp -L --remove-destination &quot;$(readlink $out/bin/rustdoc)&quot; $out/bin/rustdoc
          cp -L --remove-destination &quot;$(readlink $out/bin/cargo)&quot; $out/bin/cargo
        &#39;&#39;;
      };
    });
</code></pre></div>
<p>Here,  <code>value.rustc</code>, <code>value.cargo</code> and similar correspond to an extracted tarball of a component. <code>symlinkJoin</code> will construct a symlink forest where each file ends up in a build result (so if I understand your question right, the symlinking happens on a per-file basis, here's what some result may look like):</p>
<div class="codehilite"><pre><span></span><code>#ls -alh result/lib/rustlib/
total 31K
dr-xr-xr-x 2 root root   9 Jan  1  1970 etc/
dr-xr-xr-x 3 root root   3 Jan  1  1970 src/
dr-xr-xr-x 4 root root   4 Jan  1  1970 x86_64-unknown-linux-gnu/
lrwxrwxrwx 1 root root  72 Jan  1  1970 components -&gt; /nix/store/q3gpyn1z1pybnim0zzz95yqfka0i4lnz-rustc/lib/rustlib/components
lrwxrwxrwx 1 root root  73 Jan  1  1970 install.log -&gt; /nix/store/q3gpyn1z1pybnim0zzz95yqfka0i4lnz-rustc/lib/rustlib/install.log
lrwxrwxrwx 1 root root  76 Jan  1  1970 manifest-cargo -&gt; /nix/store/j5nsky2in6mfmwr2wnxjqll28zg9lh4l-cargo/lib/rustlib/manifest-cargo
lrwxrwxrwx 1 root root  76 Jan  1  1970 manifest-rustc -&gt; /nix/store/q3gpyn1z1pybnim0zzz95yqfka0i4lnz-rustc/lib/rustlib/manifest-rustc
lrwxrwxrwx 1 root root  82 Jan  1  1970 manifest-rust-src -&gt; /nix/store/rrbqs17syczagmirvv74yd2r7pxqf1ln-rust-src/lib/rustlib/manifest-rust-src
lrwxrwxrwx 1 root root 107 Jan  1  1970 manifest-rust-std-x86_64-unknown-linux-gnu -&gt; /nix/store/4sfkq12kzspq1mciagfjgjgns96p129s-rust-std/lib/rustlib/manifest-rust-std-x86_64-unknown-linux-gnu
lrwxrwxrwx 1 root root  84 Jan  1  1970 rust-installer-version -&gt; /nix/store/q3gpyn1z1pybnim0zzz95yqfka0i4lnz-rustc/lib/rustlib/rust-installer-version
lrwxrwxrwx 1 root root  74 Jan  1  1970 uninstall.sh -&gt; /nix/store/q3gpyn1z1pybnim0zzz95yqfka0i4lnz-rustc/lib/rustlib/uninstall.sh*
</code></pre></div>
<p>(note how some files come from different locations than others).</p>
<p>Finally, it is necessary to "un-symlink" the <code>rustc</code>, <code>rustdoc</code> and <code>cargo</code> so that they know that their sysroot is this newly built symlink forest and not their original locations. That's what the <code>cp</code> commands in the <code>postBuild</code> do.</p>



<a name="245104015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245104015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245104015">(Jul 06 2021 at 21:58)</a>:</h4>
<p>though you can achieve the same by making e.g. a wrapper that sets the <code>--sysroot</code> argument instead.</p>



<a name="245104202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245104202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245104202">(Jul 06 2021 at 22:00)</a>:</h4>
<p>Hope that helps ^^</p>



<a name="245105625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Custom%20stdlib%20paths/near/245105625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Custom.20stdlib.20paths.html#245105625">(Jul 06 2021 at 22:16)</a>:</h4>
<p>I believe it does! But unfortunatetly it's quite the challenge to differentiate real files and symlinks in Bazel. I'll try always explicitly passing <code>--sysroot</code> but if that doesn't work I'll need to try <code>--extern</code>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>